<template>
    <div>
        <p>前端版本: {{ frontendVersion }}</p>
        <el-card title="后端版本信息">
            <el-table :data="backendVersion" stripe>
                <el-table-column prop="name" label="模块名称"></el-table-column>
                <el-table-column prop="vision" label="版本号"></el-table-column>
            </el-table>
        </el-card>
    </div>
</template>

<script lang="ts" setup name="VisionInfo">

import { reqGetArticleVision, reqGetFileleVision, reqGetMapVision, reqGetUserVision } from "@/api/info";
import { requestGetData, requestIsSuccess } from "@/api/request";
import { warningMessage } from "@/utils/message";

import { onMounted, ref } from "vue";
type backendVisionInterface = {
    name: string,
    vision: string
}
const backendVersion = ref<backendVisionInterface[]>([])
const frontendVersion = "process.env.VUE_APP_VERSION"


onMounted(async () => {
    try {
        let result = await reqGetUserVision()

        backendVersion.value.push({
            name: "user",
            vision: result.data.userServiceVision
        });

        result = await reqGetArticleVision()

        backendVersion.value.push({
            name: "article",
            vision: result.data.articleServiceVision
        });

        result = await reqGetFileleVision()

        backendVersion.value.push({
            name: "file",
            vision: result.data.fileServiceVision
        });

        result = await reqGetMapVision()

        backendVersion.value.push({
            name: "map",
            vision: result.data.mapServiceVision
        });

    } catch (error) {
        warningMessage('获取后端版本信息失败:' + error);
    }
})


</script>